﻿using Ding.Permissions.Identity.JwtBearer;
using Ding.Webs.ApiSign;
using Ding.Xml;
using System.ComponentModel;

namespace GitDC
{
    /// <summary>
    /// 站点参数设置
    /// </summary>
    [DisplayName("站点参数设置")]
    [XmlConfigFile("Config/Site.config", 15000)]
    public class SiteSetting : XmlConfig<SiteSetting>
    {
        /// <summary>网站域名</summary>
        [Description("网站域名")]
        public string Url { get; set; } = "http://localhost:7070";

        /// <summary>数据库类型：MSSQL2005, MSSQL2012, MySQL, PostgreSQL, Oracle, Sqlite</summary>
        [Description("数据库类型：MSSQL2005, MSSQL2012, MySQL, PostgreSQL, Oracle, Sqlite")]
        public string DataProvider { get; set; } = "MySQL";

        /// <summary>
        /// 验证码加密密钥
        /// </summary>
        [Description("验证码加密密钥")]
        public string CaptchaSecretKey { get; set; } = "HAOCODING";

        /// <summary>
        /// Git配置
        /// </summary>
        [Description("Git配置")]
        public GitConfig GitConfig { get; set; } = new GitConfig();

        /// <summary>
        /// 网站配置
        /// </summary>
        [Description("网站配置")]
        public WebConfig WebConfig { get; set; } = new WebConfig();

        /// <summary>
        /// Email配置
        /// </summary>
        [Description("Email配置")]
        public Email Email { get; set; } = new Email();

        /// <summary>
        /// 短信配置
        /// </summary>
        [Description("短信配置")]
        public Sms Sms { get; set; } = new Sms();

        /// <summary>
        /// Jwt配置项
        /// </summary>
        [Description("Jwt配置项")]
        public JwtAuthConfigModel JWT { get; set; } = new JwtAuthConfigModel();

        /// <summary>
        /// 是否允许生产模式下显示API接口
        /// </summary>
        [Description("是否允许生产模式下显示API接口")]
        public bool IsAllowProdutionShowSwagger { get; set; } = false;

        /// <summary>
        /// 当前语言
        /// </summary>
        [Description("当前语言")]
        public string CurrentLanguage { get; set; } = "zh-CN";

        /// <summary>
        /// Api接口校验配置
        /// </summary>
        [Description("Api接口校验配置")]
        public ApiSignOptions ApiSignOptions { get; set; } = new ApiSignOptions { RequestExpireTime = 30, RsaPrivateKey = "MIICXgIBAAKBgQDlX+bYlZHNyB0IXfE2gzhIwpuSMo2Qk6VDsgXyDihIzx5YQbvQTk6ju93wvfJhlCHNUM80z2Lfg9by95CZyaiqQfQzihJWute/D4AeGzMngLYii1I5v36yJKaw7iXj+EaGrEef/Rbgspd6SmcSbzD6krqDgvmcaMQ5NtkCTySGYwIDAQABAoGARwfuze1rjIVG8FtfIll6aZXSZXDARCBk0lTj4HSf5wQ0ynH4vmYxliTMcwvvbmZYHWPD9v+uB7elLfKaVfWMBC9kWj++uFGQ9rKbzN65zv8us8eViJ82ZUasfHvOXGcQM7+DkF1KKw+nTk+YUie5/57QGIiaKx8ztyKQfv/TkHkCQQD6b49RJh1RjH9rgKXDY8kjU9cY0oaU/zuQzj0YMDtzCXjle+hKkA/aGyfj2As/4n1zDqIXtzabrqRLPSi0HDEdAkEA6niMm5oeijztrjvyqplyj1BSAL4JDrwBA8Jp984Fy5QuQtMi15Eq3GqjOCtUokFqlWajYy12RS8IS+vAk1F9fwJBAMZLVzt15nkPukSw1I/ljvm+BO7Oo2mOvudlpdJlPm1T7romZkPD1glovykVg7LN728PAyGsHD0hB03b20Lhn7ECQQDh+GZCvEj8n3XNurbHlfVji1xMnNlr2uL7dY3dJjBNoDTpcESfDqgJH7jINHJvoa4P6IhE2Bao3IgZa08Aa8QPAkEAnUg+TqOWfKt2GU4I1XFCJriXQ4RR/NnOUDnVgj526ScG+/MBpXAKCQ8b9WnQaga5AN2r07HXBj8uwhv21IUefQ==", RsaPublicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDlX+bYlZHNyB0IXfE2gzhIwpuSMo2Qk6VDsgXyDihIzx5YQbvQTk6ju93wvfJhlCHNUM80z2Lfg9by95CZyaiqQfQzihJWute/D4AeGzMngLYii1I5v36yJKaw7iXj+EaGrEef/Rbgspd6SmcSbzD6krqDgvmcaMQ5NtkCTySGYwIDAQAB" };

        /// <summary>
        /// Jwt配置
        /// </summary>
        [Description("Jwt配置")]
        public JwtOptions JwtOptions { get; set; } = new JwtOptions { Secret = "2qyg4coej67uqrono0xdmx4y0il5dn5y7b72tlb3imba677ht1p1xlfcnh36mk5u3xzjktfara29axvzk85apfplun7oslbe1m20c148p5d519kja5wvg7lmn5v4a5ou", Issuer = "ding_identity", Audience = "ding_client", AccessExpireMinutes = 120, RefreshExpireMinutes = 125, ThrowEnabled = false };

        /// <summary>
        /// Redis配置
        /// </summary>
        [Description("Redis配置")]
        public string Redis_Configuration { get; set; } = "localhost:6379,password=asdfasdfasdfasdf,writeBuffer=1024000"; //不包含密码localhost:6379或者包含密码及其他配置localhost:6379,password=senparc,connectTimeout=1000,connectRetry=2,syncTimeout=10000,defaultDatabase=3
    }

    /// <summary>
    /// 网站配置
    /// </summary>
    [DisplayName("网站配置")]
    public class WebConfig
    {
        /// <summary>
        /// 管理后台目录
        /// </summary>
        [Description("管理后台目录")]
        public string AdminPath { get; set; } = "HaoCodingAdmin";

        /// <summary>
        /// Redis配置
        /// </summary>
        [Description("Redis配置")]
        public string Redis_Configuration { get; set; } = "localhost:6379"; //不包含密码localhost:6379或者包含密码及其他配置localhost:6379,password=senparc,connectTimeout=1000,connectRetry=2,syncTimeout=10000,defaultDatabase=3

        /// <summary>
        /// 随机库
        /// </summary>
        [Description("随机库")]
        public string RandomLibrary { get; set; } = "123456789abcdefghjkmnpqrstuvwxy";

        /// <summary>
        /// 网站名称
        /// </summary>
        [Description("网站名称")]
        public string SiteName { get; set; } = "GitDC";

        /// <summary>应用子网址</summary>
        [Description("应用子网址")]
        public string AppSubURL { get; set; } = "";
    }

    /// <summary>
    /// Git配置
    /// </summary>
    [DisplayName("Git配置")]
    public class GitConfig
    {
        /// <summary>
        /// 仓库地址
        /// </summary>
        [Description("仓库地址")]
        public string RepositoryPath { get; set; } = "";

        /// <summary>
        /// Git.exe路径
        /// </summary>
        [Description("Git.exe路径")]
        public string GitCorePath { get; set; } = "";

        /// <summary>
        /// Cache路径
        /// </summary>
        [Description("Cache路径")]
        public string CachePath { get; set; } = "";
    }

    /// <summary>
    /// Email配置
    /// </summary>
    [DisplayName("Email配置")]
    public class Email
    {
        /// <summary>
        /// 服务器地址
        /// </summary>
        public string Host { get; set; } = "";
        /// <summary>
        /// 服务器端口
        /// </summary>
        public int Port { get; set; } = 465;
        /// <summary>
        /// 邮箱账号
        /// </summary>
        public string UserName { get; set; } = "";
        /// <summary>
        /// 邮箱密码
        /// </summary>
        public string Password { get; set; } = "";
        /// <summary>
        /// 发送邮箱
        /// </summary>
        public string From { get; set; } = "";
        /// <summary>
        /// 发送邮箱的昵称
        /// </summary>
        public string FromName { get; set; } = "";
        /// <summary>
        /// 是否启用SSL,0为否,1为是
        /// </summary>
        public bool IsSSL { get; set; } = true;
    }

    /// <summary>
    /// 短信配置
    /// </summary>
    [DisplayName("短信配置")]
    public class Sms
    {
        /// <summary>
        /// 短信服务器地址
        /// </summary>
        public string Url { get; set; } = "";
        /// <summary>
        /// 短信AccessKeyId
        /// </summary>
        public string AccessKeyId { get; set; } = "";
        /// <summary>
        /// 短信AccessKeySecret
        /// </summary>
        public string AccessKeySecret { get; set; } = "";
        /// <summary>
        /// 短信签名
        /// </summary>
        public string passKey { get; set; } = "";

        /// <summary>
        /// 注册欢迎短信模板
        /// </summary>
        public string RegisterWelComBody { get; set; } = "";

        /// <summary>
        /// 烽火短信账号
        /// </summary>
        public string FengHuoName { get; set; } = "";

        /// <summary>
        /// 烽火短信密码
        /// </summary>
        public string FengHuoPassWord { get; set; } = "";
    }

    /// <summary>
    /// Jwt配置项
    /// </summary>
    [DisplayName("Jwt配置项")]
    public class JwtAuthConfigModel
    {
        /// <summary>
        /// Jwt密钥
        /// </summary>
        public string JWTSecretKey { get; set; } = "lyDqoSIQmyFcUhmmN4eBRGWWzm1ELC7owHVtStOu1YD7wYz";

        /// <summary>
        /// Web过期时间
        /// </summary>
        public double WebExp { get; set; } = 800;

        /// <summary>
        /// App过期时间
        /// </summary>
        public double AppExp { get; set; } = 800;

        /// <summary>
        /// 微信过期时间
        /// </summary>
        public double WxExp { get; set; } = 800;

        /// <summary>
        /// 其他过期时间
        /// </summary>
        public double OtherExp { get; set; } = 800;

        /// <summary>
        /// 发行人
        /// </summary>
        public string Issuer { get; set; } = "Berin";

        /// <summary>
        /// 接收人
        /// </summary>
        public string Audience { get; set; } = "GITDC";
    }
}
